Ext.define('Intranet.Desktop.controller.Store', {
	
	extend: 'Ext.app.Controller',

	views: ['Intranet.Desktop.view.Store'],
	
	init: function() {
	    this.control({
            
                'panel button[id=registerBtn]' : {
                    //click: this.registerModule
                }
            });
	},
        
        registerModule : function()
        {
            var storeView = Ext.getCmp('storeView');
            var selectionModel = storeView.getSelectionModel();
            if(selectionModel.getCount())
                {
                    var selectedRecord = selectionModel.getSelection()[0];
                    Ext.Ajax.request({
                        url: '/src/public/module/modulesusers/register',
                        
                        params: {
                            mid: selectedRecord.data.mid
                            
                        },
                        
                        success: function(response){
                            var data = Ext.decode(response.responseText);
                            loadUserModules();
                            Ext.Msg.alert('Register successful', data.msg);
                        }
                    });
                }
            else
                {
                    Ext.Msg.alert('Register', 'Select module to register!');
                }
            
            
        }
});